<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        var num = Math.floor(Math.random()*101)
        
        console.log(num)
        var i = 0;
        while(true){
            var k = Number(prompt('请输入你猜的数字（0-100)'))
            if(num==k){
                i++
                alert('恩，猜对了，一共猜了'+i+'次')
                break;
            }else if(num > k ){
                alert('猜小了，继续猜猜呢')
                i++;
            }else{
                alert('猜大了，继续猜猜呢')
                i++;
            }
        }
    </script>
</body>
</html>